
frontWidth = 216
frontHeight = 116
backWidth = 800;
backHieght = 600;

function hidePrefs() {
  _hidePrefs();
  var startingRect = new AppleRect (0, 0, backWidth, backHieght);
  var finishingRect = new AppleRect (0, 0, frontWidth, frontHeight);

  var currentRectAnimation = new AppleRectAnimation( startingRect, finishingRect, rectHandler );

  var currentAnimator = new AppleAnimator (500, 13);
  currentAnimator.addAnimation(currentRectAnimation);
  currentAnimator.start();
}

function showPrefs() {
  var startingRect = new AppleRect (0, 0, frontWidth, frontHeight);
  var finishingRect = new AppleRect (0, 0, backWidth, backHieght);
  
  var currentRectAnimation = new AppleRectAnimation(startingRect, finishingRect, rectHandler );
  var currentAnimator = new AppleAnimator (500, 13);
  currentAnimator.addAnimation(currentRectAnimation);
  currentAnimator.oncomplete = _showPrefs;
  currentAnimator.start();
}


function _showPrefs() {
  if (window.widget)
    widget.prepareForTransition("ToBack");
  $('front').hide();
  showBack();
  if (window.widget)
    setTimeout('widget.performTransition();', 0);
}

function _hidePrefs() {
  if (window.widget)
    widget.prepareForTransition("ToFront");

  $('front').show();
  hideBack();

  if (window.widget)
    setTimeout('widget.performTransition();', 0);

  $('configuration_source').value = selectedValue(getMonitorSelection())
  
  saveConfiguration();
}


function rectHandler( rectAnimation, currentRect, startingRect, finishingRect) {
  window.resizeTo(currentRect.right, currentRect.bottom);
}